package br.eng.eliseu.gwt.gestaoWeb.server.command;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

import javax.persistence.EntityManager;

import br.eng.eliseu.gwt.gestaoWeb.shared.ServiceException;

import com.google.inject.Inject;
import com.google.inject.Provider;

public abstract class BaseCommand<T> implements Callable<T>, Serializable {

	private static final long serialVersionUID = -1595570425152701883L;

	@Inject 
	Provider<EntityManager> entityManager;
	
//	@Inject Injector injector;
	
	private List<String> errors = new ArrayList<String>();

	
	public abstract T call() throws ServiceException;

//	public Injector getInjector() {
//		return injector;
//	}

	public EntityManager getEntityManager() {
		return entityManager.get();
	}

	public List<String> getErrors() {
		return errors;
	}
	
	public void addError(String error) {
		errors.add(error);
	}
	
}
